#encoding=utf-8
from actionModule.handle import base
from base.common import  retSuccess
import json

class proParam(base):
    def __init__(self):
        pass
    def saveParam(self):
        item = self.table()
        subItem={}
        for temp in self.request.params:
            subItem[temp]=self.request.params.get(temp)
        
        item.setAttr('pro_id',subItem['pro_id'])
        if subItem.has_key("id"):
            item.setAttr('id',subItem['id'])
        item.setAttr('content',json.dumps(subItem))
        item.save()
        return retSuccess("保存成功") 
    
    def qryProParam(self):
        proId=self.getPost("id")
        item=self.table.objects.filter(pro_id=proId).values()
        if len(item)==0:
            return {'pro_id':proId}
        else:
            item=item[0]
            temp=json.loads(item['content'])
            temp['id']=item['id']
            temp['pro_id']=item['pro_id']
            return temp
       
        